package com.dream.utils;

import java.util.ArrayList;
import java.util.List;

public class PageInfo<T> {

	  
	 private int totalCount;//总条数
	 private int pageSize;
     private int indexPage;
     private int totalPage;//总页数
	 private List<T>  list; //封装的查询数据
	 private  Object bean;  //封装的查询参数 回显
	 private  int startPage;
	 private  int endPage;
	 private  boolean hasPrevious;
	 private  boolean hasNext;
	 
	 private List<Integer> numbers= new ArrayList<Integer>();
	 
	public PageInfo(int totalCount, int pageSize, int indexPage, List<T> list, Object bean
			) {
		this.totalCount = totalCount;
		this.pageSize = pageSize;
		this.indexPage = indexPage;
		this.list = list;
		this.bean = bean;
	
		this.totalPage=(int) Math.ceil((double)totalCount/pageSize);//数据为double类型才生效
		
		if(totalPage <= 9) {
			startPage=1;
			endPage=totalPage;
		}else {
			
			startPage=indexPage-4;
			endPage=indexPage+4;
			
			if(startPage< 1) {
				startPage=1;
				endPage=9;
			}else if(endPage>totalPage ){
				endPage=totalPage;
				startPage=totalPage-8;
			}
		}
		
		for (int i = startPage; i <= endPage; i++) {
			numbers.add(i);
		}
	}
	public int getTotalCount() {
		return totalCount;
	}
	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getIndexPage() {
		return indexPage;
	}
	public void setIndexPage(int indexPage) {
		this.indexPage = indexPage;
	}
	public int getTotalPage() {
		return totalPage;
	}
	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}
	public List<T> getList() {
		return list;
	}
	public void setList(List<T> list) {
		this.list = list;
	}
	public Object getBean() {
		return bean;
	}
	public void setBean(Object bean) {
		this.bean = bean;
	}
	public int getStartPage() {
		return startPage;
	}
	public void setStartPage(int startPage) {
		this.startPage = startPage;
	}
	public int getEndPage() {
		return endPage;
	}
	public void setEndPage(int endPage) {
		this.endPage = endPage;
	}
	public boolean isHasPrevious() {
		return hasPrevious;
	}
	public void setHasPrevious(boolean hasPrevious) {
		this.hasPrevious = hasPrevious;
	}
	public boolean isHasNext() {
		return hasNext;
	}
	public void setHasNext(boolean hasNext) {
		this.hasNext = hasNext;
	}
	public List<Integer> getNumbers() {
		return numbers;
	}
	public void setNumbers(List<Integer> numbers) {
		this.numbers = numbers;
	}
	
	
	
}
